package com.shopping.common.core.util;

import cn.hutool.http.HttpRequest;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class ContextUtil {

    /**
     * 获取Servlet请求上下文的HttpRequest对象
     * @return 请求上下文的HttpRequest对象
     */
    public static HttpServletRequest getHttpRequest(){
        return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
    }
}
